package org.abc.fund.controller.strategy.response;

import java.math.BigDecimal;
import lombok.Builder;
import lombok.Data;
import org.abc.fund.entity.strategy.StrategyComponent;

@Data
@Builder
public class StrategyComponentResponse {
  private FundBasicInfoResponse fund;
  private BigDecimal weight;

  public static StrategyComponentResponse fromEntity(StrategyComponent component) {
    if (component == null) return null;
    return StrategyComponentResponse.builder()
        .fund(FundBasicInfoResponse.fromEntity(component.getFund())) // 递归转换
        .weight(component.getWeight())
        .build();
  }
}
